{% extends "base.html" %} {% block head %} {{ super() }}

<script src="{{url_for('static', filename='../static/js/zform.js')}}" type="text/javascript" charset="utf-8"></script>
<script>
	$(document).ready(function(){
		var form = $('#post-form').ZForm({height:300,
				errors:{{ errors_json | safe }}
			});
	});
	
</script>

<title>Main Dashboard</title>

{% endblock %}

{% block left_area %}
	{{ super() }}
	<div class="left-side-content">
		{% if user['role'] == 0 %}
		<div><a href="#">My Profile</a></div>
		{% elif user['role'] == 1 %}
		<div><a href="#">My Profile</a></div>
		<div><a href="/user_manager">User Management</a></div>
		{% endif%}
	</div>

{% endblock %}

{% block content %}

	<form id="post-form" action="/manage_posts" method="post">
		<div class="row form-group" name="subject">
			<div class="col-md-5">
				<input class="form-control z-input" type="text" placeholder="{{ 'Subject' }}" />
			</div>
			<div class="col-md-5">
				<div class="z-label">{{ 'Subject' }}</div>
			</div>
		</div>

		<div class="row form-group" name="body">
			<div class="col-md-5">
				<textarea class="form-control z-input" rows="5"
								placeholder="{{ post }}"></textarea>
			</div>
			<div class="col-md-5">
				<div class="z-label">{{ 'Post' }}</div>
			</div>
		</div>

		<input class="hide" type="text" name="mode" value="new"/>

		<div class="row col-md-11">
			<div class="btn-toolbar col-md-7 z-btn-area">
				<button type="submit" class="z-submit-btn submit btn btn-primary col-md-2">Submit</button>
			</div>
		</div>
	</form>


		<form id="post-list-form" action="/manage_posts" method="post">
			<div class="panel-body">

				<div>

					<table id="post-table" class="table" mode="normal"
						style="height: 200px; overflow: auto;">
						<tbody>
							{% if posts !=[] %}
							
								{% if user['role'] == "0" %}
									{% for post in posts %}
										<tr>
											<td name="subject">{{post['subject']}}</td>
											<td name="body">{{post['body']}}</td>
											<td name="author">{{post['author']}}</td>
											<td name="created">{{post['created']}}</td>
										</tr>
									{% endfor %}								
								{% else %}
									{% for post in posts %}
										<tr>
											<td><input type="checkbox" name="selected" value="{{ None }}"></td>
											<td name="subject">{{post['subject']}}</td>
											<td name="body">{{post['body']}}</td>
											<td name="author">{{post['author']}}</td>
											<td name="created">{{post['created']}}</td>
										</tr>
									{% endfor %}
								{% endif %}
							{% endif %}
						</tbody>
					</table>
				</div>
				<br />
				<p>Rows 1-10 of 48</p>
			</div>

		</form>
{% endblock %}

{% block right_area %}
	<div class="right-side-area col-md-2">
	
	</div>
{% endblock %}